<?php

namespace App\Http\Controllers\Admin\Server\Tencent;

use App\Http\Controllers\Admin\Server\BaseServerController;
use App\Services\Server\Tencent\TencentCloud\TencentCloudService;
use Exception;
use Illuminate\Http\JsonResponse;

class TencentCloudController extends BaseServerController
{

    private TencentCloudService $tencentCloudService;

    public function __construct()
    {
        parent::__construct();
        $this->tencentCloudService = $this->loadService('Server\Tencent\TencentCloud\TencentCloudService');
    }

    /**
     * 上传文件
     *
     * @return JsonResponse
     * @throws Exception
     */
    public function uploadFile(): JsonResponse
    {
        $result = $this->tencentCloudService->uploadFile($this->params);
        return outputJsonResult($result);
    }

    /**
     * 获取上传token
     *
     * @return JsonResponse
     * @throws Exception
     */
    public function getUploadToken(): JsonResponse
    {
        $uploadToken = $this->tencentCloudService->getUploadToken($this->params);
        return outputJsonResult($uploadToken);
    }
}
